package com.example.movie.Controller;

import com.example.movie.Entity.Movie;
import com.example.movie.Service.MovieService;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/filmlist")
@CrossOrigin(origins = "*")
public class MovieController {
    private final MovieService movieService;

    public MovieController(MovieService movieService) {
        this.movieService = movieService;
    }

    @GetMapping
    public List<Movie> getAllMovies(
        @RequestParam(required = false) String title,
        @RequestParam(required = false) String region,
        @RequestParam(required = false) String genre,
        @RequestParam(required = false) Integer year) {
        return movieService.getFilteredMovies(title, region, genre, year);
    }

    @GetMapping("/filter-options")
    public Map<String, List<String>> getFilterOptions() {
        return movieService.getFilterOptions();
    }
}